package com.lumyc.store.controller;

import com.lumyc.store.util.JsonResult;
import com.lumyc.store.entity.User;
import com.lumyc.store.service.UserService;
import jdk.nashorn.internal.ir.CallNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

//@Controller
//@ResponseBody
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;
    @RequestMapping("/findUserByUid")
    public JsonResult findUserByUid(String uid){
        User user = userService.findUserByUid(uid);
        return new JsonResult<>(OK,"success",user);
    }
    @RequestMapping("/register")
    public JsonResult registerUser(User user){
        userService.register(user);
        return new JsonResult(OK, "用户注册成功！", user);
    }
    @RequestMapping("/findAll")
    public JsonResult findAll(){
        List<User> allUsers = userService.findAllUsers();
        return new JsonResult(OK,"success",allUsers);
    }
}
